﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using W_Fish.Models;

namespace W_Fish.Controllers
{
    
    
    public class PosterViewController : Controller
    {
        FishManagement_Timkiemx db = new FishManagement_Timkiemx();

        private static string USER;
        //
        // GET: /PosterView/
        #region[Main]
        
        /// <summary>
        /// Phân ra làm các mảng cho người dùng có thể click truc tiep => thuc hien các chuc nang// thiet ke sau
        /// </summary>
        /// <returns></returns>
        public ActionResult MainPoster(string user)
        {

            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
            return View();
        }
        #endregion
        #region[AddPCOFG]
        public ActionResult AddPCOFG(int id_all, string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;           
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
            List<SelectListItem> dropdownItems = new List<SelectListItem>();

            switch (id_all)
            {
                case 1:
                    {
                        ViewBag.head = "Thêm ngành mới";                        
                        break;
                    }
                case 2:
                    {
                        ViewBag.head = "Thêm lớp mới";
                        ViewBag.khac = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
                        var AllItem = (from a in db.Phyla where a.Ph_kiemduyet == true select a).ToList();
                        foreach (Phylum item in AllItem)
                        {
                            dropdownItems.Add(new SelectListItem() { Text = item.PhylumName, Value = item.PhylumID.ToString() });
                        }
                        break;
                    }
                case 3:
                    {
                        ViewBag.khac = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
                        ViewBag.head = "Thêm bộ mới";
                        var AllItem = (from a in db.ClassFish where a.Cl_kiemduyet == true select a).ToList();
                        foreach (ClassFish item in AllItem)
                        {
                            dropdownItems.Add(new SelectListItem() { Text = item.ClassName, Value = item.ClassID.ToString() });
                        }
                        break;
                    }
                case 4:
                    {
                        ViewBag.khac = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
                        ViewBag.head = "Thêm họ mới";
                        var AllItem = (from a in db.Ordoes where a.Or_kiemduyet == true select a).ToList();
                        foreach (Ordo item in AllItem)
                        {
                            dropdownItems.Add(new SelectListItem() { Text = item.OrdoName, Value = item.OrdoID.ToString() });
                        }
                        break;
                        
                    }
                case 5:
                    {
                        ViewBag.khac = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
                        ViewBag.head = "Thêm chi mới";
                        var AllItem = (from a in db.Familias where a.Fa_kiemduyet == true select a).ToList();
                        foreach (Familia item in AllItem)
                        {
                            dropdownItems.Add(new SelectListItem() { Text = item.FamilialName, Value = item.FamiliaID.ToString() });
                        }
                        break;
                        
                    }
                default:
                    {
                        break;
                    }
            }
           
            ViewData.Add("DropDownItems", dropdownItems);
            ID_ALL = id_all;
            USER = user;
            return View();
        }

        static int ID_ALL;
    [HttpPost]

        public ActionResult AddPCOFG(FormCollection collection)
        {
            int iluachon = int.Parse(collection["luachon"]);
            string sh = collection["sinhhoc"];
            string pb = collection["phanbo"];
            string ten = collection["ten"];
           
            switch (ID_ALL)
            {
                case 1:
                    {
                        int max = 0;
                        var sph = (from _sph in db.Phyla select _sph).ToList();
                        foreach (Phylum i in sph)
                        {
                            if (max < i.PhylumID) max = i.PhylumID;
                        }
                        Phylum Ph = new Phylum();
                        Ph.PhylumID = max + 1;
                        Ph.PhylumName = ten;
                        Ph.PhylumBiology = sh;
                        Ph.PhylumHabitat = pb;
                         Ph.Ph_kiemduyet = false;
                        Ph.Ph_Sign = USER;
                        Ph.Ph_Date = DateTime.Now;
                        db.Phyla.Add(Ph);
                        break;
                    }
                case 2:
                    {
                        int max = 0;
                        var S = (from _s in db.ClassFish select _s).ToList();
                        foreach (ClassFish i in S)
                        {
                            if (max < i.ClassID) max = i.ClassID;
                        }
                        ClassFish Cl = new ClassFish();
                        Cl.ClassID = max + 1;
                        Cl.ClassName = ten;
                        Cl.ClassBiology = sh;
                        Cl.ClassHabitat = pb;
                        Cl.Cl_Sign = USER;
                        Cl.Cl_kiemduyet = false;
                        Cl.Cl_Date = DateTime.Now;
                        Cl.IdPh = iluachon;
                        db.ClassFish.Add(Cl);
                        break;
                    }
                case 3:
                    {
                        int max = 0;
                        var S = (from _s in db.Ordoes select _s).ToList();
                        foreach (Ordo i in S)
                        {
                            if (max < i.OrdoID) max = i.OrdoID;
                        }
                        Ordo Cl = new Ordo();
                        Cl.OrdoID = max + 1;
                        Cl.OrdoName = ten;
                        Cl.OrdoBiology = sh;
                        Cl.OrdoHabitat = pb;
                        Cl.Or_Sign = USER;
                        Cl.Or_kiemduyet = false;
                        Cl.Or_Date = DateTime.Now;
                        Cl.ClassID = iluachon;
                        db.Ordoes.Add(Cl);

                        break;
                    }
                case 4:
                    {
                        int max = 0;
                        var S = (from _s in db.Familias select _s).ToList();
                        foreach (Familia i in S)
                        {
                            if (max < i.FamiliaID) max = i.FamiliaID;
                        }
                        Familia Cl = new Familia();
                        Cl.FamiliaID = max + 1;
                        Cl.FamilialName = ten;
                        Cl.FamilialBiology = sh;
                        Cl.FamilialHabitat = pb;
                        Cl.Fa_Sign = USER;
                        Cl.Fa_kiemduyet = false;
                        Cl.Fa_Date = DateTime.Now;
                        Cl.OrdoID = iluachon;
                        db.Familias.Add(Cl);
                       
                        break;

                    }
                case 5:
                    {
                        int max = 0;
                        var S = (from _s in db.Genus select _s).ToList();
                        foreach (Genu i in S)
                        {
                            if (max < i.GenusID) max = i.GenusID;
                        }
                        Genu Cl = new Genu();
                        Cl.GenusID = max + 1;
                        Cl.GenusName = ten;
                        Cl.GenusBiology = sh;
                        Cl.GenusHabitat = pb;
                        Cl.Ge_Sign = USER;
                        Cl.Ge_kiemduyet = false;
                        Cl.Ge_Date = DateTime.Now;
                        Cl.FamiliaID = iluachon;
                        db.Genus.Add(Cl);
                        break;

                    }
                default:
                    {
                        break;
                    }
            }
            db.SaveChanges();
            return RedirectToAction("ListView", new { evi = -1, id_View = ID_ALL, ttd = 1, user = USER });
        }

        #endregion       
        #region[AddFish]
        public static int ID_FI;
        public ActionResult AddFish( string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
            ViewBag.khac = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            List<SelectListItem> dropdownItems = new List<SelectListItem>();
            var AllItem = (from _allitem in db.Genus where _allitem.Ge_kiemduyet == true select _allitem).ToList<Genu>();
            foreach (Genu item in AllItem)
            {
                dropdownItems.Add(new SelectListItem() { Text = item.GenusName, Value = item.GenusID.ToString() });
            }
            ViewData.Add("DropDownItems1", dropdownItems);

            dropdownItems = new List<SelectListItem>();
            dropdownItems.AddRange(new[]{
                            new SelectListItem() { Text = "Nuoc ngot ", Value = "3" },
                            new SelectListItem() { Text = "Nuoc man", Value = "2" },
                            new SelectListItem() { Text = "Nuoc lo", Value = "1" },
            });
            ViewData.Add("DropDownItems2", dropdownItems);
            USER = user;
            return View();
        }

        public int MAX = 100000;
    [HttpPost]
        public ActionResult AddFish(FormCollection collection)
        {
            int ID = 0;    
            var f = (from fi in db.Fish select fi).ToList();
            foreach (Fish f1 in f)
            {
                if ( ID < f1.FishID) ID = f1.FishID;
            }
            Fish newfish = new Fish();
            newfish.Economic = collection["Economic"];
            newfish.Fi_Date = DateTime.Now;
            newfish.Fi_kiemduyet = false;
            newfish.Fi_Sign = "Poster1";
            newfish.FishHabitatVN = collection["FishHabitatVN"];
            newfish.FishHabittatW = collection["FishHabitatW"];
            newfish.FishName = collection["FishName"];
            newfish.GenusID = int.Parse(collection["luachon"]);
            newfish.Growth = collection["Growth"];
            newfish.FishID = ID + 1;           
            newfish.NameVN = collection["NameVN"];
            newfish.Nomerclature = collection["Nomerclature"];
            newfish.Nutrition = collection["Nutrition"];
            newfish.Resourcce = collection["Resourcce"];
            try
            {
                newfish.Hh_Max = float.Parse(collection["Hh_Max"]);
            }
            catch 
            {
                newfish.Hh_Max = MAX;
            }
            try { newfish.Hh_Min = float.Parse(collection["Hn_Min"]); }
            catch { newfish.Hh_Min = -1; }
            try { newfish.lcdccd_Max = float.Parse(collection["lcdccd_Max"]); }
            catch{newfish.lcdccd_Max = MAX;}
            try { newfish.LcmaxLcmin_Min = float.Parse(collection["LcmaxLcmin_Min"]); }
            catch { newfish.LcmaxLcmin_Min = -1; }
            try { newfish.Loccd_Max = float.Parse(collection["Loccd_Max"]); }
            catch{newfish.Loccd_Max = MAX;}
            try { newfish.Loccd_Min = float.Parse(collection["Loccd_Min"]); }
            catch { newfish.Loccd_Min = -1; }
            try { newfish.LodaD_Max = float.Parse(collection["LodaD_Max"]); }
            catch { newfish.LodaD_Max = MAX; }
            try { newfish.LodaD_Min = float.Parse(collection["LodaD_Min"]); }
            catch { newfish.LodaD_Min = -1; }
            try { newfish.LoH_Max = float.Parse(collection["LoH_Max"]); }
            catch { newfish.LoH_Max = MAX; }
            try { newfish.LoH_Min = float.Parse(collection["LoH_Min"]); }
            catch { newfish.LoH_Min = -1; }
            try { newfish.Lolcd_Max = float.Parse(collection["Lolcd_Max"]); }
            catch { newfish.Lolcd_Max = MAX; }
            try { newfish.Lolcd_Min = float.Parse(collection["Lolcd_Min"]); }
            catch { newfish.Lolcd_Min = -1; };
            try { newfish.LoT_Max = float.Parse(collection["LoT_Max"]); }
            catch { newfish.LoT_Max = MAX; }
            try { newfish.LoT_Min = float.Parse(collection["LoT_Min"]); }
            catch { newfish.LoT_Min = -1; }
            try { newfish.OOO_Max = float.Parse(collection["OOO_Max"]); }
            catch { newfish.OOO_Max = MAX; }
            try { newfish.OOO_Min = float.Parse(collection["OOO_Min"]); }
            catch { newfish.OOO_Min = -1; }
            try { newfish.PVVA_Max = float.Parse(collection["PVVA_Max"]); }
            catch { newfish.PVVA_Max = MAX; }
            try { newfish.PVVA_Min = float.Parse(collection["PVVA_Min"]); }
            catch { newfish.PVVA_Min = -1; }
            try { newfish.Tccd_Max = float.Parse(collection["Tccd_Max"]); }
            catch { newfish.Tccd_Max = MAX; }
            try { newfish.Tccd_Min = float.Parse(collection["Tccd_Min"]); }
            catch { newfish.Tccd_Min = -1; }
            try { newfish.Tlcd_Max = float.Parse(collection["Tlcd_Max"]); }
            catch { newfish.Tlcd_Max = MAX; }
            try { newfish.Tlcd_Min = float.Parse(collection["Tlcd_Min"]); }
            catch { newfish.Tlcd_Min = -1; }
            try { newfish.TO_Max = float.Parse(collection["TO_Max"]); }
            catch { newfish.TO_Max = MAX; }
            try { newfish.TO_Min = float.Parse(collection["TO_Min"]); }
            catch { newfish.TO_Min = -1; }
            try { newfish.TOO_Max = float.Parse(collection["TOO_Max"]); }
            catch { newfish.TOO_Max = MAX; }
            try { newfish.TOO_Min = float.Parse(collection["TOO_Min"]); }
            catch { newfish.TOO_Min = -1; }
            try { newfish.TOt_Max = float.Parse(collection["TOt_Max"]); }
            catch { newfish.TOt_Max = MAX; }
            try { newfish.TOt_Min = float.Parse(collection["TOt_Min"]); }
            catch { newfish.TOt_Min = -1; }
            string image = "";
            if(collection["image1"] != "" )
            {
                image = collection["image1"];
            }
            if (collection["image2"] != "")
            {
                image += "[x]" + collection["image2"];
            }
            if (collection["image3"] != "")
            {
                image += "[x]" + collection["image3"];
            }
            if (collection["image4"] != "")
            {
                image += "[x]" + collection["image4"];
            }
            if (collection["image5"] != "")
            {
                image += "[x]" + collection["image5"];
            }
            newfish.Fi_Sign = USER;
            newfish.Environment = int.Parse(collection["moitruong"]);
            newfish.image = image;
            db.Fish.Add(newfish);
            db.SaveChanges();                       
            return RedirectToAction("ListView", new {evi= -1, id_View = 6, ttd = 2, user = USER });
        }
        #endregion
        #region [ListView]
        /// <summary>
        /// Hiển thị dạnh sách loài, lớp, bộ, họ, chi,loài, ngành. dưới hình thức lựa chọn= > submit => View list danh sách
        /// Với mỗi một đối tượng trong danh sách có các lựa chọn xóa, update. Ngoài ra còn chức năng thêm mới.
        /// </summary>
        /// <param name="id_View"> 0,1,2,3,4,5 tương ứng với ngành, lớp, bộ, họ, chi, loài</param>
        /// <returns> </returns>
        public ActionResult ListView(int evi, int id_View , int ttd , string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
            List<SelectListItem> dropdownItems = new List<SelectListItem>();
            dropdownItems.AddRange(new[]{
                            new SelectListItem() { Text = " Theo Tên", Value = "1"},
                            new SelectListItem() { Text = "Ngày cập nhật", Value = "2" },});                         
            ViewData.Add("DropDownItems", dropdownItems);

            string chuoi= "";
            if (ttd == 1)
            {
                if (evi == -1) 
                {
                    switch (id_View)
                    {
                        case 1:
                            {
                                ViewBag.head = "Danh sách ngành";
                                var Ph = (from _ph in db.Phyla where _ph.Ph_kiemduyet == true orderby _ph.PhylumName select _ph).ToList<Phylum>();
                                int i = 1;
                                foreach (Phylum a in Ph)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=1&&id_each=" + a.PhylumID + "&&user=" + user + "\">" + a.PhylumName + "</a></td> ";
                                    chuoi += "<td>" + a.Ph_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 2:
                            {
                                ViewBag.head = "Danh sách lớp";
                                var Cl = (from _cl in db.ClassFish  where _cl.Cl_kiemduyet == true orderby _cl.ClassName select _cl).ToList<ClassFish>();
                                int i = 1;
                                foreach (ClassFish a in Cl)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=2&&id_each=" + a.ClassID + "&&user=" + user + "\">" + a.ClassName + "</a></td> ";
                                    chuoi += "<td>" + a.Cl_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 3:
                            {
                                ViewBag.head = "Danh sách bộ";
                                var Or = (from _or in db.Ordoes where _or.Or_kiemduyet == true orderby _or.OrdoName select _or).ToList<Ordo>();
                                int i = 1;
                                foreach (Ordo a in Or)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=3&&id_each=" + a.OrdoID + "&&user=" + user + "\">" + a.OrdoName + "</a></td> ";
                                    chuoi += "<td>" + a.Or_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 4:
                            {
                                ViewBag.head = "Danh sách họ";
                                var Fa = (from _fa in db.Familias where _fa.Fa_kiemduyet== true orderby _fa.FamilialName select _fa).ToList<Familia>();
                                int i = 1;
                                foreach (Familia a in Fa)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=4&&id_each=" + a.FamiliaID + "&&user=" + user + "\">" + a.FamilialName + "</a></td> ";
                                    chuoi += "<td>" + a.Fa_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 5:
                            {
                                ViewBag.head = "Danh sách chi";
                                var Ge = (from _ge in db.Genus where _ge.Ge_kiemduyet == true orderby _ge.GenusName select _ge).ToList<Genu>();
                                int i = 1;
                                foreach (Genu a in Ge)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=5&&id_each=" + a.GenusID + "&&user=" + user + "\">" + a.GenusName + "</a></td> ";
                                    chuoi += "<td>" + a.Ge_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 6:
                            {
                                ViewBag.head = "Danh sách loài cá";
                                var Fi = (from _fi in db.Fish where _fi.Fi_kiemduyet == true orderby _fi.FishName select _fi).ToList<Fish>();
                                int i = 1;
                                foreach (Fish a in Fi)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewFish?id_fish=" + a.FishID + "&&user=" + user + "\">" + a.FishName + "</a></td> ";
                                    chuoi += "<td>" + a.Fi_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        default: break;
                    }
                }
                else
                {
                    if (evi ==1)ViewBag.head = "Danh sách cá sống nước lợ";
                    if (evi == 2) ViewBag.head = "Danh sách cá nước mặn";
                    if (evi == 3) ViewBag.head = "Danh sách cá nước ngọt";
                    var Fi = (from _fi in db.Fish where _fi.Environment==evi && _fi.Fi_kiemduyet == true orderby _fi.FishName select _fi).ToList<Fish>();
                    int i = 1;
                    foreach (Fish a in Fi)
                    {
                        chuoi += "<tr> ";
                        chuoi += "<td> " + i + ". </td> ";
                        chuoi += "<td><a href=\"/PosterView/ViewFish?id_fish=" + a.FishID + "&&user=" + user + "\">" + a.FishName + "</a></td> ";
                        chuoi += "<td>" + a.Fi_Date + "</td> ";
                        chuoi += "</tr> ";
                        i++;
                    }
                }
               
            }
            if (ttd == 2)
            {
                if (evi == -1)
                {
                    switch (id_View)
                    {
                        case 1:
                            {
                                ViewBag.head = "Danh sách ngành";
                                var Ph = (from _ph in db.Phyla where _ph.Ph_kiemduyet == true orderby _ph.Ph_Date descending select _ph).ToList<Phylum>();
                                int i = 1;
                                foreach (Phylum a in Ph)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=1&&id_each=" + a.PhylumID + "&&user=" + user + "\">" + a.PhylumName + "</a></td> ";
                                    chuoi += "<td>" + a.Ph_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 2:
                            {
                                ViewBag.head = "Danh sách lớp";
                                var Cl = (from _cl in db.ClassFish where _cl.Cl_kiemduyet == true orderby _cl.Cl_Date descending select _cl).ToList<ClassFish>();
                                int i = 1;
                                foreach (ClassFish a in Cl)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=2&&id_each=" + a.ClassID + "&&user=" + user + "\">" + a.ClassName + "</a></td> ";
                                    chuoi += "<td>" + a.Cl_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 3:
                            {
                                ViewBag.head = "Danh sách bộ";
                                var Or = (from _or in db.Ordoes where _or.Or_kiemduyet == true orderby _or.Or_Date descending select _or).ToList<Ordo>();
                                int i = 1;
                                foreach (Ordo a in Or)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=3&&id_each=" + a.OrdoID + "&&user=" + user + "\">" + a.OrdoName + "</a></td> ";
                                    chuoi += "<td>" + a.Or_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 4:
                            {
                                ViewBag.head = "Danh sách họ";
                                var Fa = (from _fa in db.Familias where _fa.Fa_kiemduyet == true orderby _fa.Fa_Date descending select _fa).ToList<Familia>();
                                int i = 1;
                                foreach (Familia a in Fa)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=4&&id_each=" + a.FamiliaID + "&&user=" + user + "\">" + a.FamilialName + "</a></td> ";
                                    chuoi += "<td>" + a.Fa_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 5:
                            {
                                ViewBag.head = "Danh sách chi";
                                var Ge = (from _ge in db.Genus where _ge.Ge_kiemduyet == true orderby _ge.Ge_Date descending select _ge).ToList<Genu>();
                                int i = 1;
                                foreach (Genu a in Ge)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewPhy?id_all=5&&id_each=" + a.GenusID + "&&user=" + user + "\">" + a.GenusName + "</a></td> ";
                                    chuoi += "<td>" + a.Ge_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        case 6:
                            {
                                ViewBag.head = "Danh sách loài cá";
                                var Fi = (from _fi in db.Fish where _fi.Fi_kiemduyet == true orderby _fi.Fi_Date descending select _fi).ToList<Fish>();
                                int i = 1;
                                foreach (Fish a in Fi)
                                {
                                    chuoi += "<tr> ";
                                    chuoi += "<td> " + i + ". </td> ";
                                    chuoi += "<td><a href=\"/PosterView/ViewFish?id_fish=" + a.FishID + "&&user=" + user + "\">" + a.FishName + "</a></td> ";
                                    chuoi += "<td>" + a.Fi_Date + "</td> ";
                                    chuoi += "</tr> ";
                                    i++;
                                }
                                break;
                            }
                        default: break;
                    }
                }
                else
                {
                    if (evi == 1) ViewBag.head = "Danh sách cá sống nước lợ";
                    if (evi == 2) ViewBag.head = "Danh sách cá nước mặn";
                    if (evi == 3) ViewBag.head = "Danh sách cá nước ngọt";
                    var Fi = (from _fi in db.Fish where _fi.Environment == evi && _fi.Fi_kiemduyet == true orderby _fi.Fi_Date descending select _fi).ToList<Fish>();
                    int i = 1;
                    foreach (Fish a in Fi)
                    {
                        chuoi += "<tr> ";
                        chuoi += "<td> " + i + ". </td> ";
                        chuoi += "<td><a href=\"/PosterView/ViewFish?id_fish=" + a.FishID + "&&user=" + user + "\">" + a.FishName + "</a></td> ";
                        chuoi += "<td>" + a.Fi_Date + "</td> ";
                        chuoi += "</tr> ";
                        i++;
                    }
                }
               

            }
            ID_VIEW = id_View;
            EVI = evi;
            USER = user;
            ViewBag.body = chuoi;
            return View();
        }

        public static int ID_VIEW { get; set; }
        static int EVI;
       
        [HttpPost]
        
        public ActionResult ListView(FormCollection collection)
        {
            
            int sss = int.Parse(collection["luachon"]);
            return RedirectToAction("ListView", new { evi = EVI, id_View = ID_VIEW, ttd = sss, user = USER});
        }
        #endregion
        #region[ChangeInfo]
        public ActionResult ChangeInfo( string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user;   
            ViewBag.PosterName = user;
            var Post = (from _post in db.Posters where _post.name == user select _post).ToList();
            Poster poster = new Poster();
            poster = Post.First();
            ViewBag.name = user;
            ViewData["fullname"] = poster.fullname;
            ViewData["phonenumber"] = poster.phone;
            ViewData["email"] = poster.mail;
            ViewData["infomation"] = poster.information;
            USER = user;
            return View();
        }

        [HttpPost]

        public ActionResult ChangeInfo(FormCollection collection)
        {
            Poster poster = new Poster();
            poster = (from p in db.Posters where p.name == USER select p).ToList().First();           
            poster.fullname = collection["fullname"];
            poster.phone = int.Parse(collection["phonenumber"]);
            poster.mail = collection["email"];
            poster.information = collection["information"];

            UpdateModel(poster);
            db.SaveChanges();

            return RedirectToAction("MainPoster", new { user = USER});

        }


        #endregion
        #region[ViewPhy]

        public ActionResult ViewPhy(int id_all, int id_each, string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
           
            switch (id_all)
            {
                case 1:
                    {
                        var Phy = (from _phy in db.Phyla where _phy.PhylumID == id_each && _phy.Ph_kiemduyet==true select _phy).ToList<Phylum>();
                        var Cl = (from _cl in db.ClassFish where _cl.IdPh == id_each && _cl.Cl_kiemduyet== true select _cl).ToList<ClassFish>();                       
                        string chuoi= "";
                        int ii= 1;
                        foreach (ClassFish mem in Cl)
                        {
                            chuoi += "<a href=\"/PosterView/ViewPhy?id_all=2&&id_each=" + mem.ClassID + "&&user="+user+"\">" + ii + ". " + mem.ClassName + " </a> <br />";
                            ii = ii + 1;
                        }
                        ViewBag.List = chuoi;
                        ViewBag.Name = "Ngành "+ Phy.First().PhylumName;
                        ViewBag.SH = Phy.First().PhylumBiology;
                        ViewBag.live = Phy.First().PhylumHabitat;
                        ViewBag.LinkBack = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
                        break;
                    }
                case 2:
                    {
                        var Cls = (from _cls in db.ClassFish where _cls.ClassID == id_each && _cls.Cl_kiemduyet == true select _cls).ToList<ClassFish>();
                        var Or = (from _or in db.Ordoes where _or.ClassID == id_each && _or.Or_kiemduyet == true select _or).ToList<Ordo>();
                        ViewBag.Name = "Lớp "+ Cls.First().ClassName;
                        ViewBag.SH = Cls.First().ClassBiology;
                        ViewBag.live = Cls.First().ClassHabitat;
                        string chuoi = "";
                        int ii = 1;
                        foreach (Ordo mem in Or)
                        {
                            chuoi += "<a href=\"/PosterView/ViewPhy?id_all=3&&id_each=" + mem.OrdoID + "&&user=" + user + "\">" + ii + ". " + mem.OrdoName + " </a> <br />";
                            ii = ii + 1;
                        }
                        ViewBag.LinkBack = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=2&&user=" + user;
                        ViewBag.List = chuoi;
                        break;
                    }
                case 3:
                    {
                        var Or = (from _or in db.Ordoes where _or.OrdoID == id_each && _or.Or_kiemduyet == true select _or).ToList<Ordo>();
                        var Fa = (from _fa in db.Familias where _fa.OrdoID == id_each && _fa.Fa_kiemduyet == true select _fa).ToList<Familia>();
                        ViewBag.Name = "Bộ " + Or.First().OrdoName;
                        ViewBag.SH = Or.First().OrdoBiology;
                        ViewBag.live = Or.First().OrdoHabitat;
                        string chuoi = "";
                        int ii = 1;
                        foreach (Familia mem in Fa)
                        {
                            chuoi += "<a href=\"/PosterView/ViewPhy?id_all=4&&id_each=" + mem.FamiliaID + "&&user=" + user + "\">" + ii + ". " + mem.FamilialName + " </a> <br />";
                            ii = ii + 1;
                        }
                        ViewBag.LinkBack = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
                  
                        ViewBag.List = chuoi;
                        break;
                    }
                case 4:
                    {
                        var Fa = (from _fa in db.Familias where _fa.FamiliaID == id_each && _fa.Fa_kiemduyet == true select _fa).ToList<Familia>();
                        var Ge = (from _ge in db.Genus where _ge.FamiliaID == id_each && _ge.Ge_kiemduyet == true select _ge).ToList<Genu>();
                        ViewBag.Name = "Họ " + Fa.First().FamilialName;
                        ViewBag.SH = Fa.First().FamilialBiology;
                        ViewBag.live = Fa.First().FamilialHabitat;
                        string chuoi = "";
                        int ii = 1;
                        foreach (Genu mem in Ge)
                        {
                            chuoi += "<a href=\"/PosterView/ViewPhy?id_all=5&&id_each=" + mem.GenusID + "&&user=" + user + "\">" + ii + ". " + mem.GenusName + " </a> <br />";
                            ii = ii + 1;
                        }

                        ViewBag.List = chuoi;
                        ViewBag.LinkBack = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
                  
                        break;
                    }
                case 5:
                    {
                        var Ge = (from _ge in db.Genus where _ge.GenusID == id_each && _ge.Ge_kiemduyet == true select _ge).ToList<Genu>();
                        var Fi = (from _fi in db.Fish where _fi.GenusID == id_each && _fi.Fi_kiemduyet == true select _fi).ToList<Fish>();
                        ViewBag.Name = "Chi "+ Ge.First().GenusName;
                        ViewBag.SH = Ge.First().GenusBiology;
                        ViewBag.live = Ge.First().GenusHabitat;
                        string chuoi = "";
                        int ii = 1;
                        foreach (Fish mem in Fi)
                        {
                            chuoi += "<a href=\"/PosterView/ViewFish?id_fish=" + mem.FishID + "&&user=" + user + "\">" + ii + ". " + mem.FishName + " </a> <br />";
                            ii = ii + 1;
                        }
                        ViewBag.LinkBack = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;                  
                        ViewBag.List = chuoi;
                        break;
                    }
                default:
                    {
                        break;
                    }
            }
            
            return View();
        }
        #endregion
        #region[ViewFish]
        int Max = 100000;
        public ActionResult ViewFish(int id_fish, string user)
        {
            ViewBag.l1a = "/PosterView/AddPCOFG?id_all=1&&user=" + user;
            ViewBag.l1b = "/PosterView/AddPCOFG?id_all=2&&user=" + user;
            ViewBag.l1c = "/PosterView/AddPCOFG?id_all=3&&user=" + user;
            ViewBag.l1d = "/PosterView/AddPCOFG?id_all=4&&user=" + user;
            ViewBag.l1e = "/PosterView/AddPCOFG?id_all=5&&user=" + user;
            ViewBag.l2 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l3 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l4 = "/PosterView/ChangeInfo?id_poster&&user=" + user;
            ViewBag.l5 = "/PosterView/ListView?evi=-1&&id_View=1&&ttd=1&&user=" + user;
            ViewBag.l6 = "/PosterView/ListView?evi=-1&&id_View=2&&ttd=1&&user=" + user;
            ViewBag.l7 = "/PosterView/ListView?evi=-1&&id_View=3&&ttd=1&&user=" + user;
            ViewBag.l8 = "/PosterView/ListView?evi=-1&&id_View=4&&ttd=1&&user=" + user;
            ViewBag.l9 = "/PosterView/ListView?evi=-1&&id_View=5&&ttd=1&&user=" + user;
            ViewBag.l10 = "/PosterView/ListView?evi=-1&&id_View=6&&ttd=1&&user=" + user;
            ViewBag.l12 = "/PosterView/AddFish?id_fi=-1&&user=" + user;
            ViewBag.l13 = "/PosterView/ListView?evi=3&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l14 = "/PosterView/ListView?evi=2&&id_View=-1&&ttd=1&&user=" + user;
            ViewBag.l15 = "/PosterView/ListView?evi=1&&id_View=-1&&ttd=1&&user=" + user; 
            ViewBag.PosterName = user;
            string a = "";
            var info = (from tt in db.Fish where tt.FishID == id_fish && tt.Fi_kiemduyet == true select tt);

            Fish cur = new Fish();
            cur = info.First();

            int Ge_ID = cur.GenusID;
            var ge = (from ttge in db.Genus where ttge.GenusID == Ge_ID && ttge.Ge_kiemduyet == true select ttge);

            int Fa_ID = ge.First().FamiliaID;
            var fa = (from ttfa in db.Familias where ttfa.FamiliaID == Fa_ID && ttfa.Fa_kiemduyet == true select ttfa);

            int Or_ID = fa.First().OrdoID;
            var or = (from ttor in db.Ordoes where ttor.OrdoID == Or_ID && ttor.Or_kiemduyet == true select ttor);

            int Cl_ID = or.First().ClassID;
            var cl = (from ttcl in db.ClassFish where ttcl.ClassID == Cl_ID && ttcl.Cl_kiemduyet == true select ttcl);


            ClassFish myclass = new ClassFish();
            myclass = cl.First();

            int Ph_ID = myclass.IdPh;

            var ph = (from ttph in db.Phyla where ttph.PhylumID == Ph_ID && ttph.Ph_kiemduyet == true select ttph);


            string[] listimage = info.First().image.Split(new string[] { "[x]" }, StringSplitOptions.None);


            int ii = 1;
            a += "<center>";
            foreach (string image in listimage)
            {
                if (ii % 2 == 0)
                {
                    a += "<img height= \"100\" width= \"200\" src=\"" + image + "\" /><br />";

                }
                else
                {
                    a += "<img height= \"100\" width= \"200\" src=\"" + image + "\" />";
                }
                ii++;
            }

            a += "<h3 style=\"color: #0033CC\">" + cur.FishName + "</h3>";
            a += "</center>";
            a += "<br />";
            a += "<a href = \"/User/ListPhylum?id_phylum=" + ph.First().PhylumID + "\"> Ngành " + ph.First().PhylumName + " </a>";
            a += "<br />";
            a += "<a href = \"/User/ListClass?id_class=" + cl.First().ClassID + "\"> Lớp " + cl.First().ClassName + " </a>";
            a += "<br />";
            a += "<a href = \"/User/ListOrdo?id_ordo=" + or.First().OrdoID + "\"> Bộ " + or.First().OrdoName + " </a>";
            a += "<br />";
            a += "<a href = \"/User/ListFamily?id_family=" + fa.First().FamiliaID + "\"> Họ " + fa.First().FamilialName + " </a>";
            a += "<br />";
            a += "<a href = \"/User/ListGenus?id_genus=" + ge.First().GenusID + "\"> Chi " + ge.First().GenusName + " </a>";
            a += "<br />";
            a += "<h4><i style=\"color: #990000; margin-left: 50px;\">1. Tên cá </i></h4>";
            a += "<p>";
            a += "•	Tên loài: " + cur.FishName;
            a += "<br />";
            a += "•	Tên chính thức: " + cur.MainName;
            a += "<br />";
            a += "•	Tên danh pháp: " + cur.Nomerclature;
            a += "<br />";
            a += "•	Tên Việt Nam: " + cur.NameVN;
            a += "<br />";
            a += "</p>";
            a += "<h4><i style=\"color: #990000 ; margin-left: 50px;\">2. Phân bố </i></h4>";
            a += "<p>";
            a += "Trong nước:" + cur.FishHabitatVN;
            a += "<br />";
            a += "Thế giới:" + cur.FishHabittatW;
            a += "<br />";
            a += "</p>";
            a += "<h4><i style=\"color: #990000 ; margin-left: 50px;\">3. Mô tả hình thái và dữ liệu sinh học </i></h4>";
            a += "<p>";
            a += "Tập tính sống: " + cur.LivingHabit;
            a += "<br />";
            a += "Dinh dướng: " + cur.Nutrition;
            a += "<br />";
            a += "Sinh trưởng: " + cur.Growth;
            a += "<br />";
            a += "Sinh sản: " + cur.Reproduction;
            a += "<br />";
            a += "</p>";
            a += "<h4><i style=\"color: #990000 ; margin-left: 50px;\">4. Đặc điểm hình thái</i></h4>";
            a += "<p>";
            if (cur.LoH_Min < 0 && cur.LoH_Max < Max) { a += "•	*Lo/H: < " + cur.LoH_Max + " <br /> "; }
            if (cur.LoH_Min > 0 && cur.LoH_Max > Max) { a += "•	*Lo/H: >" + cur.LoH_Min + " <br /> "; }
            if (cur.LoH_Min > 0 && cur.LoH_Max < Max) { a += "•	*Lo/H: " + cur.LoH_Min + " - " + cur.LoH_Max + " <br /> "; }
            if (cur.LoT_Min < 0 && cur.LoT_Max < Max) { a += "•	*Lo/T: <" + cur.LoT_Max + "<br /> "; }
            if (cur.LoT_Min > 0 && cur.LoT_Max > Max) { a += "•	*Lo/T: >" + cur.LoT_Min + "<br /> "; }
            if (cur.LoT_Min > 0 && cur.LoT_Max < Max) { a += "•	*Lo/T: " + cur.LoT_Min + " - " + cur.LoT_Max + "<br /> "; }

            if (cur.Lolcd_Min < 0 && cur.Lolcd_Max < Max) { a += "•	  Lo/lcd: <" + cur.Lolcd_Max + " <br /> "; }
            if (cur.Lolcd_Min > 0 && cur.Lolcd_Max > Max) { a += "•	  Lo/lcd: >" + cur.Lolcd_Min + " <br /> "; }
            if (cur.Lolcd_Min > 0 && cur.Lolcd_Max < Max) { a += "•	  Lo/lcd: " + cur.Lolcd_Min + " - " + cur.Lolcd_Max + " <br /> "; }

            if (cur.Loccd_Min < 0 && cur.Loccd_Max < Max) { a += "•	  Lo/ccd: <" + cur.Loccd_Max + " <br /> "; }
            if (cur.Loccd_Min > 0 && cur.Loccd_Max > Max) { a += "•	  Lo/ccd: >" + cur.Loccd_Min + " <br /> "; }
            if (cur.Loccd_Min > 0 && cur.Loccd_Max < Max) { a += "•	  Lo/ccd: " + cur.Loccd_Min + " - " + cur.Loccd_Max + " <br /> "; }

            if (cur.TOt_Min < 0 && cur.TOt_Max < Max) { a += "•	  T/Ot: <" + cur.TOt_Max + " <br /> "; }
            if (cur.TOt_Min > 0 && cur.TOt_Max > Max) { a += "•	  T/Ot: >" + cur.TOt_Min + " <br /> "; }
            if (cur.TOt_Min > 0 && cur.TOt_Max < Max) { a += "•	  T/Ot: " + cur.TOt_Min + " - " + cur.TOt_Max + " <br /> "; }

            if (cur.TO_Min < 0 && cur.TO_Max < Max) { a += "•	T/O: <" + cur.TO_Max + " <br /> "; }
            if (cur.TO_Min > 0 && cur.TO_Max > Max) { a += "•	T/O: >" + cur.TO_Min + " <br /> "; }
            if (cur.TO_Min > 0 && cur.TO_Max < Max) { a += "•	T/O: " + cur.TO_Min + " - " + cur.TO_Max + " <br /> "; }

            if (cur.TOO_Min < 0 && cur.TOO_Max < Max) { a += "•	  T/OO: <" + cur.TOO_Max + " <br /> "; }
            if (cur.TOO_Min > 0 && cur.TOO_Max > Max) { a += "•	  T/OO: >" + cur.TOO_Min + " <br /> "; }
            if (cur.TOO_Min > 0 && cur.TOO_Max < Max) { a += "•	  T/OO: " + cur.TOO_Min + " - " + cur.TOO_Max + " <br /> "; }

            if (cur.Tlcd_Min < 0 && cur.Tlcd_Max < Max) { a += "•	T/lcd: <" + cur.Tlcd_Max + " <br /> "; }
            if (cur.Tlcd_Min > 0 && cur.Tlcd_Max > Max) { a += "•	T/lcd: >" + cur.Tlcd_Min + " <br /> "; }
            if (cur.Tlcd_Min > 0 && cur.Tlcd_Max < Max) { a += "•	T/lcd: " + cur.Tlcd_Min + " - " + cur.Tlcd_Max + " <br /> "; }

            if (cur.Tccd_Min < 0 && cur.Tccd_Max < Max) { a += "•	T/ccd: <" + cur.Tccd_Max + " <br /> "; }
            if (cur.Tccd_Min > 0 && cur.Tccd_Max > Max) { a += "•	T/ccd: >" + cur.Tccd_Min + " <br /> "; }
            if (cur.Tccd_Min > 0 && cur.Tccd_Max < Max) { a += "•	T/ccd: " + cur.Tccd_Min + " - " + cur.Tccd_Max + " <br /> "; }

            if (cur.Hh_Min < 0 && cur.Hh_Max < Max) { a += "•   H/h: <" + cur.Hh_Max + " <br /> "; }
            if (cur.Hh_Min > 0 && cur.Hh_Max > Max) { a += "•	H/h: >" + cur.Hh_Min + " <br /> "; }
            if (cur.Hh_Min > 0 && cur.Hh_Max < Max) { a += "•	H/h: " + cur.Hh_Min + " - " + cur.Hh_Max + " <br /> "; }

            if (cur.OOO_Min < 0 && cur.OOO_Max < Max) { a += "•	  OO/O: <" + cur.OOO_Max + " <br /> "; }
            if (cur.OOO_Min > 0 && cur.OOO_Max > Max) { a += "•	  OO/O: >" + cur.OOO_Min + " <br /> "; }
            if (cur.OOO_Min > 0 && cur.OOO_Max < Max) { a += "•	  OO/O: " + cur.OOO_Min + " - " + cur.OOO_Max + " <br /> "; }

            if (cur.lcdccd_Min < 0 && cur.lcdccd_Max < Max) { a += "•	lcd/ccd: <" + cur.lcdccd_Max + " <br /> "; }
            if (cur.lcdccd_Min > 0 && cur.lcdccd_Max > Max) { a += "•	lcd/ccd: >" + cur.lcdccd_Min + " <br /> "; }
            if (cur.lcdccd_Min > 0 && cur.lcdccd_Max < Max) { a += "•	lcd/ccd: " + cur.lcdccd_Min + " - " + cur.lcdccd_Max + " <br /> "; }

            if (cur.LcmaxLcmin_Min < 0 && cur.LcmaxLcmin_Max < Max) { a += "•	Lcmax/Lcmim: <" + cur.LcmaxLcmin_Max + " <br /> "; }
            if (cur.LcmaxLcmin_Min > 0 && cur.LcmaxLcmin_Max > Max) { a += "•	Lcmax/Lcmim: >" + cur.LcmaxLcmin_Min + " <br /> "; }
            if (cur.LcmaxLcmin_Min > 0 && cur.LcmaxLcmin_Max < Max) { a += "•	Lcmax/Lcmim: " + cur.LcmaxLcmin_Min + " - " + cur.LcmaxLcmin_Max + " <br /> "; }

            if (cur.LodaD_Min < 0 && cur.LodaD_Max < Max) { a += "•	  Lo/daD: <" + cur.LodaD_Max + " <br /> "; }
            if (cur.LodaD_Min > 0 && cur.LodaD_Max > Max) { a += "•	  Lo/daD: >" + cur.LodaD_Min + " <br /> "; }
            if (cur.LodaD_Min > 0 && cur.LodaD_Max < Max) { a += "•	  Lo/daD: " + cur.LodaD_Min + " - " + cur.LodaD_Max + " <br /> "; }

            if (cur.PVVA_Min < 0 && cur.PVVA_Max < Max) { a += "•	P-V/V-A: <" + cur.PVVA_Max + " <br /> "; }
            if (cur.PVVA_Min > 0 && cur.PVVA_Max > Max) { a += "•	P-V/V-A: >" + cur.PVVA_Min + " <br /> "; }
            if (cur.PVVA_Min > 0 && cur.PVVA_Max < Max) { a += "•	P-V/V-A: " + cur.PVVA_Min + " - " + cur.PVVA_Max + " <br /> "; }

            a += "</p>";
            a += "<h4><i style=\"color: #990000 ; margin-left: 50px;\">5. Giá trị sử dụng </i></h4>";
            a += "<p>";
            a += "Giá trị khoa học: " + cur.Scientific;
            a += "<br />";
            a += "Giá trị kinh tế: " + cur.Economic;
            a += "<br />";
            a += "Hiện trạng nguồn lợi: " + cur.Resourcce;
            a += "<br />";
            a += "</p>";
            string mt = "";
            switch (cur.Environment)
            {
                case 1:
                    {
                        mt = "Nước lợ .";
                        break;
                    }
                case 2:
                    {
                        mt = "Nước mặn. ";
                        break;
                    }
                case 3:
                    {
                        mt = "Nước ngọt. ";
                        break;
                    }
                default: { break; }
            }

            a += "</p>";
            a += "<h4><i style=\"color: #990000; margin-left: 50px;\">6. Môi trường sống: </i></h4>" + mt;
            a += "<p>";

            ViewBag.tt = a;

            cur.CountAccess = cur.CountAccess + 1;
            UpdateModel(cur);
            db.SaveChanges();

            ViewBag.LinkBack = "<a href=\"/PosterView/ListView?evi=-1&&id_all=6&&ttd=1&&user=" + user + "\">Quay lại</a>";
            return View();
        }
        #endregion


    }
}
